<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <title>登录</title>
    <script type="text/javascript" src="/jquery-1.11.1.min.js"></script>
  
  </head>
<body>

<form id="uploadfile"   target="iframeUpload">  
    <iframe name="iframeUpload" src="" width="350" height="35" frameborder=0  SCROLLING="no" style="display:NONE"></iframe>  
    <input id="test_file" name="test_file" type="file">  
     <input type="button" value="上传" onclick="doUpload()" />  
</form>
<img alt="" src="" id="img">

<script type="text/javascript">
function doUpload() {  
    var formData = new FormData($( "#uploadfile" )[0]);  
    $.ajax({  
         url: "uploadfile" ,  
         type: 'POST',  
         data: formData,  
         async: false,  
         cache: false,  
         contentType: false,  
         processData: false,  
         success: function (returndata) {  
             alert(returndata); 
             $("#img").attr("src",returndata);
         },  
         error: function (returndata) {  
             alert(returndata);  
         }  
    });  
}  

</script>
</body>
</html>
